package com.sharemarking.application.common.repository;

import java.util.Date;
import java.util.List;


import org.springframework.data.jpa.repository.Query;

import com.sharemarking.application.common.BaseRepository;
import com.sharemarking.application.common.entity.Equitment;


public interface EquitmentRepo extends BaseRepository<Equitment>{
	@Query("select e from Equitment e where (e.startTime<?1 and e.endTime>?4) and ( (e.startTime>?2 and e.startTime<?3)or (e.startTime<?2 and e.endTime>?3) or (e.endTime>?2 and e.endTime<?3) or (e.endTime=?2 and e.endTime=?3) )")
	List<Equitment> findByTime(Date time1,Date time2,Date time3,Date time4);
	
	@Query("select e from Equitment e where e.startTime>?1 and ( (e.startTime>?2 and e.startTime<?3)or (e.startTime<?2 and e.endTime>?3) or (e.endTime>?2 and e.endTime<?3) or (e.endTime=?2 and e.endTime=?3) )")
	List<Equitment> findByTime1(Date time1,Date time2,Date time3);
	
	List<Equitment> findByemployee_idOrderByUpdateDateDesc(Integer id);
}
